package com.itheima.holder;

import com.itheima.pojo.UmsAdmin;

public class AdminLocal {
    public static ThreadLocal<UmsAdmin>local=new ThreadLocal<>();
    //向当前线程存储数据
    public static void set(UmsAdmin admin) {
        local.set(admin);
    }

    //从当前线程获取数据
    public static UmsAdmin getAdmin() {
        return local.get();
    }

    public static void remove() {
        local.remove();
    }

    //获取当前用户的id
    public static Long getUserId() {
        return local.get().getId();
    }
}
